
package Navigation;

import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

class StreetTopologyObjectImpl implements ITopologyObject {

	private String gaoID = "";
	private ITopologyObject[] coordinates;
	
    public StreetTopologyObjectImpl(String content) {
    	String[] parseStreetContent = content.split("\\;");
    	String[] coordinates = parseStreetContent[0].split("\\s");
    	List<CoordinateTopologyObjectImpl> coordinateList = new ArrayList<CoordinateTopologyObjectImpl>();
    	for(int i=0;i<coordinates.length;i++){
    		String[] coordinateContent = coordinates[i].split("\\,");
    		double x = Double.parseDouble(coordinateContent[0]);
    		double y = Double.parseDouble(coordinateContent[1]);
    		coordinateList.add(new CoordinateTopologyObjectImpl(x, y));
    	}
    	this.gaoID = parseStreetContent[1];
    	this.coordinates = (ITopologyObject[])coordinateList.toArray(new ITopologyObject[]{});
    }

    public String write() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public String getGaoID(){
    	return gaoID;
    }
}
